<?php

namespace App\Transformers\Permission;

use App\Models\Permission;
use League\Fractal\TransformerAbstract;

class PermissionTransformer extends TransformerAbstract
{
    public function transform(Permission $data)
    {
        return [
            'id' => $data->id,
            'name' => $data->name ?? '',
            'cn_name' => $data->cn_name8 ?? '',
            'guard_name' => $data->guard_name ?? '',
            'pid' => $data->pid ?? 0,
            'level' => $data->level ?? '',
            'parameter' => $data->parameter ?? '',
            'mode' => $data->mode ?? '',
            'sort' => $data->sort ?? 0,
            'status' => $data->status ?? 1,
            'type' => $data->type ?? '',
            'is_hidden' => $data->is_hidden ?? 0,
            'interfacepath' => $data->interfacepath ?? '',
            'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : '',
        ];
    }

}

